package com.czapl.mygdxgame;


import api.CGame;
import api.IGame;
import api.IPlayer;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.utils.Array;
import com.czapl.api.ITower;
import com.czapl.api.IUnit;
import com.czapl.drawing.CTower;
import com.czapl.towers.ArrowTower;
import com.czapl.towers.CannonTower;
import com.czapl.towers.FireTower;
import com.czapl.towers.IceTower;

public class MyGdxGame extends Game {
	public static Skin skin = null;
	public static TextureAtlas towerAtlas = null;
	public static TextureAtlas unitAtlas;
	public static final int AVAILABLE_UNIT_COUNT = 1;
	public static final int AVAILABLE_TOWER_COUNT = 4;
	public static final Array<ITower> TowerInstances = new Array<ITower>();
	public static final Array<IUnit> UnitInstances = new Array<IUnit>();
	
	
	@Override
	public void create() {	
		skin = new Skin(Gdx.files.internal("skins/uiresources.json"));

		towerAtlas = new TextureAtlas(Gdx.files.internal("data/towers/resources.atlas"));
		unitAtlas = new TextureAtlas(Gdx.files.internal("data/towers/resources.atlas"));
		//Sprite sprite = textureAtlas.createSprite("cannon1");
		TowerInstances.add(new FireTower());
		TowerInstances.add(new IceTower());
		TowerInstances.add(new ArrowTower());
		TowerInstances.add(new CannonTower());
		//UnitInstances.add(new CUnit(new Sprite(new Texture(Gdx.files.internal("data/units/unit1.png")))));
		setScreen(new MainScreen());
		
		IGame game = CGame.connectToServer("192.168.0.3", 8200);
	      //game.register("wojtik8", "dupka2");
	      IPlayer player = game.login("wojtik8", "dupka2");
	      player.logout();
	      game.ping();
	}

	@Override
	public void dispose() {
		super.dispose();
	}

	@Override
	public void render() {		
		super.render();
	}

	@Override
	public void resize(int width, int height) {
		super.resize(width, height);
	}

	@Override
	public void pause() {
		super.pause();
	}

	@Override
	public void resume() {
		super.resume();
	}
}
